import * as Cesium from "cesium";
export const init =async () => {
  const viewer = new Cesium.Viewer("cesiumContainer", {
    animation: false,
    fullscreenButton: false,
    vrButton: false,
    geocoder: false,
    homeButton: false,
    sceneModePicker: false,
    timeline: false,
    // baseLayer: new Cesium.ImageryLayer(
    //   new Cesium.UrlTemplateImageryProvider({
    //     url: "http://webst01.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}",
    //     minimumLevel: 0,
    //   })
    // ),
    // terrain: new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("model/yunnan"))
     terrainProvider: await Cesium.CesiumTerrainProvider.fromUrl('model/yunnan')
  });
  // viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
  //   url: "model/yunnan"
  // });
  let imagel = new Cesium.ImageryLayer(
    new Cesium.UrlTemplateImageryProvider({
      url: "http://webst01.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}",
      minimumLevel: 0,
      maximumLevel: 18
    })
  );
  viewer.imageryLayers.add(imagel);

  // viewer.entities.add({
  //   position: Cesium.Cartesian3.fromDegrees(116.391, 39.907, 1000),
  //   model: {
  //     uri: "model/tif/ASTGTMV003_N24E102_dem.tif",
  //     minimumPixelSize: 50,
  //     color: Cesium.Color.RED,
  //     silhouetteColor: Cesium.Color.YELLOW,
  //     silhouetteSize: 1
  //     // scale: 1.5,
  //     // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  //   }
  // });

  //   const pointCollect = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());

  //   for (let i = 0; i < 200; i++) {
  //     for (let j = 0; j < 200; j++) {
  //       pointCollect.add({
  //         position: Cesium.Cartesian3.fromDegrees(i, j * 0.1 ),
  //         color: Cesium.Color.fromRandom({ alpha: 1.0 }),
  //         pixelSize: 1,
  //         outlineColor: Cesium.Color.RED,
  //         outlineWidth: 1
  //       });
  //     }
  //   viewer.zoomTo(pr);
};
